package com.huike.web.controller.report;

import java.util.List;
import java.util.Map;

import com.huike.report.domain.vo.LineChartVO;
import com.huike.report.domain.vo.VulnerabilityMapVo;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.TbClue;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.contract.domain.TbContract;
import com.huike.report.domain.vo.ActivityStatisticsVo;
import com.huike.report.service.IReportService;


/**
 * 报告控制器
 *
 * @author zhouao
 * @date 2022/05/14
 */
@RestController
@RequestMapping("/report")
public class ReportController extends BaseController {

    /**
     * 报告服务
     */
    @Autowired
    private IReportService reportService;

    /**
     * 合同统计
     * 客户统计
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link LineChartVO}
     */
    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO contractStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return reportService.contractStatistics(beginCreateTime, endCreateTime);
    }

    /**
     * 销售统计
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link LineChartVO}
     */
    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO salesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return reportService.salesStatistics(beginCreateTime, endCreateTime);
    }


    /**
     * 香奈儿统计数据
     * 渠道统计
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link AjaxResult}
     */
    @GetMapping("/chanelStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult chanelStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return AjaxResult.success(reportService.chanelStatistics(beginCreateTime, endCreateTime));
    }


    /**
     * 活动统计
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link AjaxResult}
     */
    @GetMapping("/activityStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult activityStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return AjaxResult.success(reportService.activityStatistics(beginCreateTime, endCreateTime));
    }

    /**
     * 合同统计列表
     * 查询活动管理列表
     *
     * @param contract 合同
     * @return {@link TableDataInfo}
     */

    @GetMapping("/contractStatisticsList")
    public TableDataInfo contractStatisticsList(TbContract contract) {
        startPage();
        List<TbContract> list = reportService.contractReportList(contract);
        return getDataTable(list);
    }


    /**
     * 部门统计列表
     * 销售统计部门报表
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link TableDataInfo}
     */
    @GetMapping("/deptStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo deptStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        startPage();
        List<Map<String, Object>> list = reportService.deptStatisticsList(beginCreateTime, endCreateTime);
        return getDataTablePage(list);
    }

    /**
     * 频道统计列表
     * 销售统计渠道报表
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link TableDataInfo}
     */
    @GetMapping("/channelStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo channelStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        startPage();
        List<Map<String, Object>> list = reportService.channelStatisticsList(beginCreateTime, endCreateTime);
        return getDataTablePage(list);
    }

    /**
     * 主人船统计列表
     * 销售统计归属人报表
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link TableDataInfo}
     */
    @GetMapping("/ownerShipStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo ownerShipStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        startPage();
        List<Map<String, Object>> list = reportService.ownerShipStatisticsList(beginCreateTime, endCreateTime);
        return getDataTablePage(list);
    }


    /**
     * 线索统计列表
     * 线索统计报表
     *
     * @param clue 线索
     * @return {@link TableDataInfo}
     */
    @GetMapping("/cluesStatisticsList")
    public TableDataInfo cluesStatisticsList(TbClue clue) {
        startPage();
        List<TbClue> list = reportService.cluesStatisticsList(clue);
        return getDataTable(list);
    }

    /**
     * 活动统计列表
     * 活动渠道统计
     *
     * @param activity 活动
     * @return {@link TableDataInfo}
     */
    @GetMapping("/activityStatisticsList")
    public TableDataInfo activityStatisticsList(TbActivity activity) {
        List<ActivityStatisticsVo> list = reportService.activityStatisticsList(activity);
        return getDataTablePage(list);
    }

    /**
     * 统计图表的参数
     *
     * @param :
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/17 12:05
     */
    @GetMapping("/subjectStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult subjectStatistics(
            @PathVariable("beginCreateTime") String beginCreateTime,
            @PathVariable("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.subjectStatistics(beginCreateTime, endCreateTime));

    }

    /**
     * 线状图 线索统计
     *
     * @param beginCreateTime:开始时间
     * @param endCreateTime:结束时间
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/17 15:00
     */
    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult cluesStatistics(@PathVariable("beginCreateTime") String beginCreateTime,
                                      @PathVariable("endCreateTime") String endCreateTime) {

        return AjaxResult.success(reportService.cluesStatistics(beginCreateTime, endCreateTime));
    }

    /**
     * 统计分析--线索统计--线索转化率漏斗图
     *
     * @param :
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/17 16:52
     */
    @GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public AjaxResult getVulnerabilityMap(@PathVariable("beginCreateTime") String beginCreateTime,
                                          @PathVariable("endCreateTime") String endCreateTime) {
       /* VulnerabilityMapVo vulnerabilityMapVo = ;*/
        return AjaxResult.success(reportService.getVulnerabilityMap(beginCreateTime, endCreateTime));

    }
}
